package com.example.java.designpattern.adapter;

import com.example.java.designpattern.Divisor;

/**
 * @author zengty
 * @apiNote 对象适配器模式
 * @date 2024/8/30
 * @project study
 */
public class DivisorAdapter implements Divisor {

    /**
     * 被适配者
     */
    private final Adaptee adaptee;

    public DivisorAdapter(Adaptee adaptee) {
        this.adaptee = adaptee;
    }

    @Override
    public void divide(String target) {
        adaptee.sampleMethod(target);
    }

    @Override
    public boolean isSupport(String target) {
        return Math.random() > 0.5;
    }
}
